import javax.annotation.processing.SupportedSourceVersion;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;



public class Answer2 {
    //分组
    // 暴力枚举（举例组最多人数）+二分
    static int n,m;
    static Map<Integer,Integer> hash=new HashMap<>();

    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        n=in.nextInt();m=in.nextInt();
        int hmax=0;
        for(int i=0;i<n;i++){
            int x=in.nextInt();
            hash.put(x,hash.getOrDefault(x,0)+1);
            hmax=Math.max(x,hmax);
        }

        int kinds=hash.size();
        if(kinds > m) System.out.println("-1");
        else{
            int l=1,r=hmax;
            while(l<r){
                int mid=(l+r) /2;
                if(check(mid)) r=mid;
                else l=mid+1;

            }
            System.out.println(l);
        }
    }

    public static boolean check(int mid){
        int g=0;
        for(int a : hash.values()){
            g += a%mid == 0 ?a/mid : (a/mid +1);
        }

        return g==mid;
    }
}
